package com.bigegg.employee.service;

import cn.hutool.extra.qrcode.QrCodeUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.OutputStream;


/**
 * 二维码service
 */
@Service
public class QRCodeService {


    /**
     * 在 yml配置文件中配置evn.product 设置部署环境地址
     */
    @Value("${evn.product}")
    private String evnProduct;


    /**
     * 生成单位签到二维码
     *
     * @param actId        活动ID
     * @param unitId       单位ID
     * @param outputStream 输出
     */

    public void generateUnitSignQRCode(Long actId, Long unitId, OutputStream outputStream) {
        QrCodeUtil.generate(evnProduct + "/unit?activity_id=" + actId + "&unit_id=" + unitId, 360, 360, "png", outputStream);
    }

    /**
     * 生成活动签到二维码
     *
     * @param actId        活动ID
     * @param outputStream 输出
     */
    public void generateActivitySignQRCode(Long actId, OutputStream outputStream) {
        QrCodeUtil.generate(evnProduct + "/activity?activity_id=" + actId, 360, 360, "png", outputStream);
    }


}
